part of '../page.dart';

class _ImageFloor extends StatelessWidget {
  const _ImageFloor({
    required this.color,
    required this.height,
    Key? key,
  }) : super(key: key);

  final Color color;
  final double height;

  @override
  Widget build(BuildContext context) {
    return ClipPath(
      clipper: _Clipper(),
      child: Container(
        height: height,
        width: double.infinity,
        color: color,
      ),
    );
  }
}

class _Clipper extends CustomClipper<Path> {
  double _getArcRadius({
    required double arcHeight,
    required double arcWidth,
  }) {
    return arcHeight / 2 + arcWidth * arcWidth / arcHeight / 8;
  }

  @override
  Path getClip(Size size) {
    final width = size.width;
    final height = size.height;
    final path = Path();

    final arcHeight1 = height / 10;
    final arcHeight2 = height / 5;

    final arcRadius1 = _getArcRadius(
      arcHeight: arcHeight1,
      arcWidth: width,
    );
    final arcRadius2 = _getArcRadius(
      arcHeight: arcHeight2,
      arcWidth: width,
    );

    path.arcToPoint(
      Offset(width, 0),
      clockwise: false,
      largeArc: false,
      radius: Radius.circular(arcRadius1),
    );

    path.lineTo(width, height - arcHeight2);

    path.arcToPoint(
      Offset(0, height - arcHeight2),
      clockwise: true,
      largeArc: false,
      radius: Radius.circular(arcRadius2),
    );

    path.lineTo(0, 0);

    return path;
  }

  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) => true;
}
